import { FormManagement as locale } from './locale';
import {
  createInbizSchema,
  createComponentStyleSchema,
  createDecoratorStyleSchema,
} from '@inbiz/setters';

export const defaultProps = {
  queryRegion: '当前应用',
};

export const defaultDecoratorProps = {
  style: { height: '100%', padding: '10px 10px 10px 10px' },
};

export const Schema = createInbizSchema({
  attribute: {
    base: {
      type: 'void',
      'x-component': 'CollapseItem',
      properties: {
        'x-display': {
          type: 'string',
          enum: ['visible', 'hidden'],
          'x-decorator': 'FormItem',
          'x-component': 'Select',
          'x-component-props': {
            defaultValue: 'visible',
          },
        },
        'x-component-props': {
          type: 'object',
          properties: {
            //查询区域
            queryRegion: {
              type: 'string',
              'x-decorator': 'FormItem',
              'x-component': 'Select',
              enum: [
                'now',
                'all',
              ],
            },
          },
        },
      },
    },
  },
  style: {
    ...createComponentStyleSchema(),
    ...createDecoratorStyleSchema(),
  },
});

export const defaultResource = {
  icon: 'FormManagement',
  elements: [
    {
      componentName: 'Field',
      props: {
        type: 'string',
        title: {
          value: 'FormManagement.title',
          status: true,
        },
        'x-decorator': 'Container',
        'x-component': 'FormManagement',
        'x-component-props': defaultProps,
        'x-decorator-props': defaultDecoratorProps,
      },
    },
  ],
};

export const defaultBehavior = {
  name: 'FormManagement',
  extends: ['Field'],
  selector: (node: any) => node.props['x-component'] === 'FormManagement',
  designerProps: { propsSchema: Schema },
  designerLocales: locale,
};
